﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using HmFramework.Components;
using HmFramework.UI.Utils;
using HmFramework.Data;
using CuteSprite.Eme.Data.CRM;

namespace CuteSprite.Eme.UI.CRM.Report
{
	public enum ExpressReportType
	{
		/// <summary>富力通运单</summary>
		ExpressMix = 0,

		/// <summary>OCS运单</summary>
		ExpressOCS = 1,

		/// <summary>OCS运单发票</summary>
		ExpressOCSInvoice = 2,

		/// <summary>富力经济线运单</summary>
		ExpressEconomyLine = 3,
	}

	public partial class FrmExpressMixTagView : HmBaseForm
	{
		public FrmExpressMixTagView(ExpressReportType reportType, DataSet ds)//EntityList<ExpressMix> expresslist)
		{
			InitializeComponent();

			// Creating and configuring the ObjectDataSource component:
			HmFramework.Reporting.ObjectDataSource objectDataSource = new HmFramework.Reporting.ObjectDataSource();
			objectDataSource.DataSource = ds.Tables[0]; // GetData returns a DataTable
			//objectDataSource.CalculatedFields.Add(new HmFramework.Reporting.CalculatedField("FullName", typeof(string), "=Fields.Name + ' ' + Fields.ProductNumber")); // Adding a sample calculated field.

			// Creating a new report
			HmFramework.Reporting.Report report = null;
			switch (reportType)
			{
				case ExpressReportType.ExpressOCS:
					report = new ExpressOCS();
					break;

				case ExpressReportType.ExpressOCSInvoice:
					report = new ExpressOCSInvoice();
					break;

				case ExpressReportType.ExpressEconomyLine:
					report = new ExpressMixTag();
					break;

				case ExpressReportType.ExpressMix:
				default:
					report = new ExpressMixTag();
					break;
			}

			// Assigning the ObjectDataSource component to the DataSource property of the report.
			report.DataSource = objectDataSource;

			// Use the InstanceReportSource to pass the report to the viewer for displaying
			HmFramework.Reporting.InstanceReportSource reportSource = new HmFramework.Reporting.InstanceReportSource();
			reportSource.ReportDocument = report;

			// Assigning the report to the report viewer.
			reportViewer1.ReportSource = reportSource;

			// Calling the RefreshReport method in case this is a WinForms application.
			reportViewer1.RefreshReport();

			InitForm();
		}


		protected override void InitComponent()
		{
			base.InitComponent();

		}
	}
}
